package InputOutputStreamDemo;


import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;

/**
 *
 *
 * 使用字符流向文件中写入数据
 *
 * */
public class WriterDemo {
    public static void main(String[] args) {
        String filePath = "C:"+ File.separator+"Users"+File.separator+"Administrator"+File.separator+"Desktop"
                +File.separator+"1"+File.separator+"test.txt";
        File file = new File(filePath);

        try {
            Writer writer = new FileWriter(file,true);//true表示内容追加
            String content = "湖北师范大学,";
            writer.write(content);
            writer.close();

        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
